﻿using AutoMapper;
using BW.MesProject.Public.ErrorCode;
using BW.MesProject.Public.Infrastructure;
using BW.MesProject.WareHouse.Domain;
using BW.MesProject.WareHouse.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BW.MesProject.WareHouse.Application
{
  
    /// <summary>
    /// 仓库类型信息
    /// </summary>
    public class WHTypeServices : IWHTypeServices
    {
        private readonly IBaseRepository<WareHouseTypeModel> _WareHouseType;
        private readonly IMapper _mapper;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="Emp"></param>
        /// <param name="mapper"></param>
        public WHTypeServices(IBaseRepository<WareHouseTypeModel> WareHouseType, IMapper mapper)
        {
            _WareHouseType = WareHouseType;
            this._mapper = mapper;
        }


        /// <summary>
        /// 查询仓库类型
        /// </summary>
        /// <param name="WareName"></param>
        /// <returns></returns>
        public ApiResult<List<WareHouseTypeModel>> GetWareHouseType(string? WareHouseTypeName)
        {
            int totalCount = 0;
            //查询名称来显示数据
            var list = _WareHouseType.GetAll();
            List<WareHouseTypeModel> WareHouseTypelist = new List<WareHouseTypeModel>();
            if (WareHouseTypeName != null)
            {
                WareHouseTypelist = list.Where(x => x.WHTypeName.Contains(WareHouseTypeName)).OrderBy(u => u.WHTypeId).ToList();
            }
            else
            {
                WareHouseTypelist = list.OrderBy(u => u.WHTypeId).ToList();
            }
            return new ApiResult<List<WareHouseTypeModel>>()
            {
                Code = ApiEnums.Success,
                Message = "查询成功",
                Data = WareHouseTypelist.ToList(),
                TotalCount = 0,
            };
        }

    }
}
